package com.red.book.activity;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.neo.duan.mvp.present.BasePresenter;
import com.neo.duan.ui.adapter.XBaseAdapter;
import com.neo.duan.ui.adapter.XBaseViewHolder;
import com.neo.duan.ui.widget.recyclerview.DividerItemDecoration;
import com.red.book.R;

import java.util.Arrays;

import butterknife.BindView;

/**
 * @author neo.duan
 * @date 2018/09/05 14:32
 * @desc 主页
 */
public class MainActivity extends BaseActivity {

    private static final String[] ARRAY = {
            "数字增长动画",
            "通知权限被禁用，自定义吐司",
            "圆形进度条：https://github.com/duanfb/CircleProgress",
            "垂直跑马灯:https://github.com/duanfb/MarqueeView",
            "ormLite数据库加密",
    };

    @BindView(R.id.rcv_main)
    RecyclerView mRecyclerView;

    MyAdapter mAdapter;

    @Override
    public void initTop() {
        enableTitle(true, "首页");
    }

    @Override
    public void initLayouts() {
        setContentView(R.layout.activity_main);
    }

    @Override
    public void initViews() {
        mRecyclerView.addItemDecoration(new DividerItemDecoration(mContext, 1f));
        mAdapter = new MyAdapter(mContext);
        mRecyclerView.setAdapter(mAdapter);

        mAdapter.setNewData(Arrays.asList(ARRAY));
    }

    @Override
    public BasePresenter initPresenter() {
        return null;
    }

    @Override
    public void initListeners() {
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                switch (position) {
                    case 0:
                        RiseNumActivity.start(mContext);
                        break;
                    default:
                        break;
                }
            }
        });
    }

    @Override
    public void initData() {

    }

    class MyAdapter extends XBaseAdapter<String> {

        public MyAdapter(Context context) {
            super(context);
        }

        @Override
        protected int getLayoutResId(int viewType) {
            return R.layout.item_list;
        }

        @Override
        protected void convert(XBaseViewHolder helper, String item) {
            helper.setText(R.id.tv_item, item);
        }
    }
}
